﻿using System;
using log4net;
using Moreeasi.TaskQueue;
using Prism.Events;
using Microsoft.Extensions.Caching.Memory;
using Modules.MSentEvent;
using Sorting.App.Models;
using Sorting.App.Models.Enum;
using Sorting.App.Services;
using Modules.Units;
using Modules.ActionRun;

namespace Lm.Core.TaskQueue;


/// <summary>
/// 任务处理主队列
/// </summary>
public class CountStoreTask : UnitTask
{



    /// <summary>
    /// 构造函数
    /// </summary>
    /// <param name="ea"></param>
    public CountStoreTask(IEventAggregator ea)
    {
        _ea = ea;
    }

    public TaskLogService _logService = new TaskLogService();
    public ShelfService shelfService = new ShelfService();

    public ILog log = LogManager.GetLogger(typeof(CountStoreTask));


    #region 属性

    IEventAggregator _ea;

    #endregion


    #region  公共方法



    #endregion

    #region 重载方法


    /// <summary>
    /// 任务处理
    /// </summary>
    /// <returns></returns>
    /// <exception cref="NotImplementedException"></exception>
    public override  void ExecuteNew()
    {
        //var data = await shelfService.GetShelfByWardNo(this.Data);

        var data = (ShelfEntity)this.Data;
        this.State = EnumTaskState.Running;

        //通知界面任务已经处理
        _ea.GetEvent<ViewModelSentEvent>().Publish(new MessageModel()
        {
            Code = EnumMessageType.ME105,
            Data = data,
            Message = $"模组A中储位{data.Code}执行"

        });

        this.State = EnumTaskState.Sucess;

        ////通知界面任务已经处理
        //_ea.GetEvent<ViewModelSentEvent>().Publish(new MessageModel()
        //{
        //    Code = EnumMessageType.ME106,
        //    Data = data,
        //    Message = $"模组B中储位{data.Code}执行"

        //});

    }

    #endregion
}